const images = [
  { src: 'https://xwx.gzzmedu.com:6899/pic/wx-x-mai/activity/bg3.png' },
  { src: 'https://xwx.gzzmedu.com:6899/pic/wx-x-mai/activity/bg1.png' },
  { src: 'https://xwx.gzzmedu.com:6899/pic/wx-x-mai/activity/bg2.png' },
]
Page({

  /**
   * 页面的初始数据
   */
  data: {
    images: [
    ],
    pageLoading: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getManageActivityList()
  },

  /**
   * @see 点击测试
   */
  itemClick (e) {
    const activity = e.currentTarget.dataset.item
    let url = `/pages/eventConfiguration/index?scene=a%3d${activity.id}%26t%3d1`
    wx.navigateTo({
      url
    })
  },

  /**
   * @see 获取活动列表
   */
  getManageActivityList () {
    this.data.pageLoading = true
    wx.showLoading({
      title: '加载中...'
    })
    wx.$API['eventConfiguration/getManageActivityList']({}).then(result => {
      result.data.forEach((v, i) => {
        v.src = images[(i + 1) % 3].src
      })
      this.setData({
        images: result.data
      })
      this.data.pageLoading = false
      wx.hideLoading()
    })
      .catch(error => {
        wx.hideLoading()
        this.data.pageLoading = false
        console.log('获取活动列表失败', error)
        wx.showToast({
          title: error,
          icon: "none"
        })
      })
  }
})